package pl.edu.agh.student.vrp;

import org.apache.commons.configuration.PropertiesConfiguration;

//<<<<<<< .mine
//public class Main
//{
//    
//    public static void main(String[] args) throws Exception
//    {
//        String f = "src/main/resources/rc101.txt";
//        GA app = new GA(new PropertiesConfiguration("src/main/resources/config.properties"));
//        app.load(new File(f));
//        app.run();
//        
//        
//=======
import java.io.File;

public class Main {

    public static void main(String[] args) throws Exception {
//        String f = "src/main/resources/r102.txt";
        PropertiesConfiguration prop = new PropertiesConfiguration("src/main/resources/config.properties");
        doTest(prop);

//        doTest(prop);


//        String f = "src/main/resources/r101";
//        
//        GA ga = new GA();
//        ga.init(prop, new File(f+ "_result.txt"));
//        ga.load(new File(f + ".txt"));
//        ga.run();
//        ga.close();

    }

    private static void doTest(PropertiesConfiguration prop) throws Exception {
        for (String filename : prop.getStringArray("inputFiles")) {
            System.out.println("doTest(): start - " + filename);
            if(filename.startsWith("c1")) {
                prop.setProperty("capacity", 200);
            } else if(filename.startsWith("c2")) {
                prop.setProperty("capacity", 700);
            } else if(filename.startsWith("r1")) {
                prop.setProperty("capacity", 200);
            } else if(filename.startsWith("r2")) {
                prop.setProperty("capacity", 1000);
            } else if(filename.startsWith("rc1")) {
                prop.setProperty("capacity", 200);
            } else if(filename.startsWith("rc2")) {
                prop.setProperty("capacity", 1000);
            }
            
            GA ga = new GA();
            ga.init(prop, new File("src/main/resources/" + filename + "_result.txt"));
            ga.load(new File("src/main/resources/" + filename + ".txt"));
            ga.run();
            ga.close();
            System.out.println("doTest(): end - " + filename+"\n********");
        }
    }

}

